<?php
	/*
	 * File: login_page.php
	 * Last modification: 20.07.2011
	 * Author(s): kivio.wanderley
	 * 
	 */
?>
	
<?php /** UPPER PHP CODE */

	# Get APIs and INCs
	$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR;
	require_once($t_core_dir . 'core_api.php');
	
	html_head_begin();
	core_require_js("jquery");
	
	core_require_css("css_default");
	html_head_end();
	
	html_begin();
	
	html_title_begin( "Login Page" );
	html_title_end();

	html_body_begin();
	
	# Start session
	if( ! isset($_SESSION) ) session_start();
?>

<?php /** MIDDLE PHP CODE */
	# Verify any user was already logged in
	if(isset($_SESSION['USER']) && 
	   isset($_SESSION['ACCESS']) && 
	   isset($_SESSION['CREATED']) && 
	   isset($_SESSION['LAST_ACTIVITY']) ) 
	{
		print_header_redirect( 'main_page.php?page=home_page' );
	}

	# Set and load the language for the page
	if( config_get_global_array() != false ) { //If theres an erro on configuration get language by browser
		lang_global_array(config_get('language'));
	
		config_unset();
	} else {
		if( strstr($_SERVER['HTTP_USER_AGENT'], "pt-BR") ) {
			lang_set_current("portuguese");
		} else {
			lang_set_current("english");
		}
		lang_global_array();
		
		config_unset();
	}

?>

<div align="center">

<form id="sub_form" name="sub_form" method="post" action="login.php">
<table id="table_lp" class="width30" style="display: none;">
	<tr class="title">
		<th colspan=3><?php echo lang_get("login_input"); ?></th>
	</tr>

	<tr class="content-center">
		<td><label><?php echo lang_get("username") . ":"; ?></label></td>
		<td><input type="text" id="log_user" name="log_user" size="25" maxlength="25" /></td>
	</tr>
	<tr class="content-center">
		<td><label><?php echo lang_get("password") . ":"; ?></label></td>
		<td><input type="password" id="log_pass" name="log_pass" size="25" maxlength="25" /></td>
	</tr>
	<tr class="content-center">
		<td>&nbsp; </td>
		<td><?php print_submit_button('subscribe_button'); ?></td>
	</tr>
</table><br />
</form>

<?php 
	if( isset($_GET['erro']) ) {
		$t_erro = "[ ERRO: ". lang_get($_GET['erro']) ." ]";
		
		PRINT '<table class="width50">';
		PRINT '<tr class="erro">';
		PRINT '<td>'.$t_erro.'</td>';
		PRINT '</tr>';
		PRINT '</table>';
	}
?>

</div>

<script>
$(document).ready(function () {
	$( "#table_lp" ).fadeIn(1500);

});
</script>

<?php /** BOTTOM PHP CODE */
		
	html_body_end();
	
	html_end();
?>	